<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>意见库--添加/修改意见</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Expires" CONTENT="0">
    <meta http-equiv="Cache-Control" content="no-siteapp,no-transform,no-store, no-cache, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <link rel="shortcut icon" href="../../../favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="../../../static/css/font.css">
    <link rel="stylesheet" href="../../../static/css/weadmin.css">
    <script type="text/javascript" src="/lib/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="../../../static/css/buildUnit/common.css">
</head>
<body>
<form class="layui-form" id="form" action="" lay-filter="suggest" style="padding:20px;">
    <div class="layui-form-item">
        <label class="layui-form-label required">条文性质</label>
        <div class="layui-input-block">
            <select name="articleType" id="articleType" class="formData" lay-verify="required" lay-filter="articleType">
                <option value="">请选择</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item" id="qiangtiaoTypeView" style="display:none;">
        <label class="layui-form-label required">强条类别</label>
        <div class="layui-input-block">
            <select name="qiangtiaoType" id="qiangtiaoType" class="formData" lay-verify="" lay-filter="qiangtiaoType">
                <option value="">请选择</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">条文编号</label>
        <div class="layui-input-block">
            <input type="text" name="tiaowenNum" lay-verify="required" placeholder="规范编号及条目" autocomplete="off"
                   class="layui-input formData">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label required">审查意见</label>
        <div class="layui-input-block">
            <textarea name="adviseTxt" lay-verify="required" placeholder="请输入内容"
                      class="layui-textarea formData"></textarea>
        </div>
    </div>
    <button lay-submit lay-filter="demo1" style="display: none;" class="demo1">确定</button>
</form>
<script src="../../../static/js/main.js"></script>
<script>
    var $;
    layui.use([ 'form', 'jquery', 'sessionFun',  'configure', 'bluebird', 'configureCom' ], function () {
        $ = layui.jquery;
        var configure = layui.configure;
        var sessionFun = layui.sessionFun;
        var form = layui.form;
        var configureCom = layui.configureCom;
        var type = configureCom.GetQueryString('type');
        //获得suggestBaseData
        var suggestBaseData = sessionFun.get(configure.SESSION_SUGGEST_BASE_DATA);
        form.render('select');
        //如果意见对象存在，则初始赋值
        if (suggestBaseData) {
            configureCom.selectDataFun(configure.ARTICLE_TYPE, suggestBaseData.articleType, '#articleType');//条文性质
            configureCom.selectDataFun(configure.QIANGTIAO_CODE, suggestBaseData.qiangtiaoType, '#qiangtiaoType');//强条类别
            if (suggestBaseData.qiangtiaoType) {
                $('#qiangtiaoTypeView').show();
            }
            form.render('select');
            form.val("suggest", suggestBaseData);
        } else {
            configureCom.selectDataFun(configure.ARTICLE_TYPE, '', '#articleType');//条文性质
            configureCom.selectDataFun(configure.QIANGTIAO_CODE, '', '#qiangtiaoType');//强条类别
        }
        //监听select
        form.on('select(articleType)', function (data) {
            var qiangtiaoTypeSelect = data.othis.parents('.layui-form-item').next('.layui-form-item');
            if (parseInt(data.value) === parseInt(configure.ARTICLE_TYPE_QIANGTIAO_VALUE)) {
                qiangtiaoTypeSelect.show();
                qiangtiaoTypeSelect.find('select').removeAttr('disabled');
            } else {
                qiangtiaoTypeSelect.hide();
                qiangtiaoTypeSelect.find('select').attr('disabled', 'disabled').val('');
            }
            form.render('select', 'qiangtiaoType');
        });
        //监听提交
        form.on('submit(demo1)', function (data) {
            return false;
        });
    });

    function getData() {
        return new Promise(function (res, rej) {
            var data = {};
            if (!window.formVerifyFun()) {
                return false;
            }
            $('.formData').each(function (index, item) {
                if (!($(item).closest('.layui-form-item').is(':hidden'))) {
                    var key = $(item).attr('name');
                    data[key] = $(item).val();
                }
            });
            res({result: data});
        });
    }
</script>
</body>
</html>